Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[16.0][MIG] l10n_be_national_number #318

Open
wants to merge 14 commits into
base: 16.0
Choose a base branch
from

Conversation

victor-champonnois
Copy link
Member

@victor-champonnois victor-champonnois commented Mar 25, 2024

l10n_be_national_number was implemented in v14 and published on https://github.com/OCA/l10n-belgium.
In v16, there is the module https://github.com/OCA/l10n-belgium/tree/16.0/l10n_be_partner_identification that does the same thing with more functionalities.

We need to migrate the data. The module l10n_be_national_number is moved here, and contain a migration script and a dependency to l10n_be_partner_identification.

internal task
https://gestion.coopiteasy.be/web?debug=1#id=12259&action=479&model=project.task&view_type=form&menu_id=536

@victor-champonnois victor-champonnois changed the title 16.0 mig l10n be national number [16.0][MIG] l10n_be_national_number Mar 25, 2024
@codecov-commenter
Copy link

codecov-commenter commented Mar 26, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 94.17%. Comparing base (e99dc87) to head (39ec13a).

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@           Coverage Diff           @@
##             16.0     #318   +/-   ##
=======================================
  Coverage   94.17%   94.17%           
=======================================
  Files          34       34           
  Lines         584      584           
  Branches       56       56           
=======================================
  Hits          550      550           
  Misses         27       27           
  Partials        7        7           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@victor-champonnois
Copy link
Member Author

@huguesdk thanks for the review, PR fixed!

Copy link
Member

@huguesdk huguesdk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for fixing the migration script. sorry, i didn’t look close enough into it the first time, so here are more remarks.

Comment on lines 6 to 17
old_id = env.ref("l10n_be_national_number.l10n_be_national_number_category")
new_id = env.ref(
"l10n_be_partner_identification.l10n_be_national_registry_number_category"
).id
for id_numbers in (
env["res.partner"]
.with_context(active_test=False)
.search([])
.mapped("id_numbers")
):
if id_numbers.category_id == old_id:
id_numbers.category_id = new_id
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually, i think this won’t work if there are multiple id_numbers on a partner, which can be the case as its a one2many relationship. instead, you should work with res.partner.id_number records directly. one way is to do it like this:

Suggested change
old_id = env.ref("l10n_be_national_number.l10n_be_national_number_category")
new_id = env.ref(
"l10n_be_partner_identification.l10n_be_national_registry_number_category"
).id
for id_numbers in (
env["res.partner"]
.with_context(active_test=False)
.search([])
.mapped("id_numbers")
):
if id_numbers.category_id == old_id:
id_numbers.category_id = new_id
old_id = env.ref("l10n_be_national_number.l10n_be_national_number_category").id
new_id = env.ref(
"l10n_be_partner_identification.l10n_be_national_registry_number_category"
).id
id_numbers = (
env["res.partner.id_number"]
.with_context(active_test=False)
.search([("category_id", "=", old_id)])
)
id_numbers.write({"category_id": new_id})

another is like this:

Suggested change
old_id = env.ref("l10n_be_national_number.l10n_be_national_number_category")
new_id = env.ref(
"l10n_be_partner_identification.l10n_be_national_registry_number_category"
).id
for id_numbers in (
env["res.partner"]
.with_context(active_test=False)
.search([])
.mapped("id_numbers")
):
if id_numbers.category_id == old_id:
id_numbers.category_id = new_id
old_id = env.ref("l10n_be_national_number.l10n_be_national_number_category").id
new_id = env.ref(
"l10n_be_partner_identification.l10n_be_national_registry_number_category"
).id
env.cr.execute(
"""
update res_partner_id_number
set category_id = %(old_id)s
where category_id = %(new_id}s
""",
{"old_id": old_id, "new_id": new_id},
)

@victor-champonnois
Copy link
Member Author

@huguesdk fixed !

Copy link
Member

@huguesdk huguesdk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@victor-champonnois
Copy link
Member Author

/ocabot merge nobump

@github-grap-bot
Copy link
Contributor

On my way to merge this fine PR!
Prepared branch 16.0-ocabot-merge-pr-318-by-victor-champonnois-bump-nobump, awaiting test results.

github-grap-bot added a commit that referenced this pull request Apr 29, 2024
Signed-off-by victor-champonnois
Copy link
Member

@polchampion polchampion left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

functional check: LGTM

@github-grap-bot
Copy link
Contributor

@victor-champonnois your merge command was aborted due to failed check(s), which you can inspect on this commit of 16.0-ocabot-merge-pr-318-by-victor-champonnois-bump-nobump.

After fixing the problem, you can re-issue a merge command. Please refrain from merging manually as it will most probably make the target branch red.

@victor-champonnois
Copy link
Member Author

/ocabot merge nobump

@github-grap-bot
Copy link
Contributor

Hey, thanks for contributing! Proceeding to merge this for you.
Prepared branch 16.0-ocabot-merge-pr-318-by-victor-champonnois-bump-nobump, awaiting test results.

github-grap-bot added a commit that referenced this pull request Apr 30, 2024
Signed-off-by victor-champonnois
@github-grap-bot
Copy link
Contributor

@victor-champonnois your merge command was aborted due to failed check(s), which you can inspect on this commit of 16.0-ocabot-merge-pr-318-by-victor-champonnois-bump-nobump.

After fixing the problem, you can re-issue a merge command. Please refrain from merging manually as it will most probably make the target branch red.

@github-grap-bot
Copy link
Contributor

This PR has the approved label and has been created more than 5 days ago. It should therefore be ready to merge by a maintainer (or a PSC member if the concerned addon has no declared maintainer). 🤖

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants